<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../public/js/vue.js"></script>
    <style>
        .action {
            background: red;
        }
    </style>
</head>
<!-- 
    v-bind: 给标签绑定属性；
    " : " v-bind 语法糖写法；
 -->
<body>
    <div id="app">
        <ul>
            <li v-for="(item, index) in message" :class="{action: index == count ? true : false}" @click="liStyle(index)">{{ item }}</li>
        </ul>
    </div>
    <script>
        const app = new Vue({
            el:"#app",
            data(){
                return {
                    message:['孔小飘','yoyo','小宝贝'],
                    count:''
                }
            },
            methods:{
                liStyle(index) {
                    this.count = index;
                }
            }
        })
    </script>
</body>
</html>